home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ddj0897.zip / RCSC.ZIP / LIB51 / ITOAB.C < prev    next >
C/C++ Source or Header  |  1997-01-12  |  445b  |  21 lines

  1. /*
  2. ** itoab(n,s,b) - Convert "unsigned" n to characters in s using base b.
  3. **                NOTE: This is a non-standard function.
  4. */
  5. itoab(n, s, b) int n; char *s; int b; {
  6.   char *ptr;
  7.   int lowbit;
  8.   ptr = s;
  9.   b >>= 1;
  10.   do {
  11.     lowbit = n & 1;
  12.     n = (n >> 1) & 32767;
  13.     *ptr = ((n % b) << 1) + lowbit;
  14.     if(*ptr < 10) *ptr += '0'; else *ptr += 55;
  15.     ++ptr;
  16.     } while(n /= b);
  17.   *ptr = 0;
  18.   reverse (s);
  19.   }
  20.  
  21.